package march.test_3_3;

import java.util.Scanner;

public class TestMain2 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String str1 = scanner.nextLine();
        String str2 = scanner.nextLine();
        int tmp = 0;
        for(int i = 0; i < str2.length(); i++) {
            if(i >= str1.length() && str1.charAt(tmp) != '*') {
                System.out.println(false);
                return;
            }
            if(str1.charAt(tmp) == '*') {
                while (str1.charAt(tmp) == '*' || str1.charAt(tmp) == '?') {
                    tmp++;
                }
                while (i < str2.length() && str1.charAt(tmp) != str2.charAt(i)) {
                    i++;
                }
                if(i >= str2.length()) {
                    System.out.println(false);
                    return;
                }
            }
            if(str1.charAt(tmp) == '?') {
                i++;
                tmp++;
            }
            if(i < str2.length() && tmp >= str1.length()) {
                System.out.println(false);
                return;
            }
            if(i < str2.length() && str1.charAt(tmp) != str2.charAt(i)) {
                System.out.println(false);
                return;
            }
        }
        System.out.println(true);
    }
}
